﻿using System;
using WeiXinPF.Common;
using WeiXinPF.Templates;

namespace WeiXinPF.Web.shop
{
    /// <summary>
    /// 名优推荐
    /// </summary>
    public partial class recommend_index : ShopBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            base.OnInit(e);

            if (!string.IsNullOrEmpty(errInitTemplates))
            {
                Response.Write(errInitTemplates);
                return;
            }

            BLL.wx_module_templates tBll = new BLL.wx_module_templates();
            templateFileName = tBll.GetTemplatesFileNameByWid("shop", wid);
            if (templateFileName == null || templateFileName.Trim() == "")
            {
                errInitTemplates = Constants.MessageNoTempate;
                Response.Write(errInitTemplates);
                Response.End();
                return;
            }

            //string openid = MyCommFun.RequestOpenid();
            var widInt = MyCommFun.RequestWid();
            var thisUrl = MyCommFun.getWebSite() + "/shop/recommend_index.aspx?wid=" + widInt;
            var bll = new BLL.wx_userweixin();
            var uWeiXinModel = bll.GetModel(widInt);
#if DEBUG
            openid = ConfigurationHelper.GetDebugOpenId();
#else
            base.OAuth2BaseProc(uWeiXinModel, "recommend_index", thisUrl);
#endif
            serverPath = MyCommFun.GetRootPath() + "/shop/templates/" + templateFileName + "/recommend_index.html";
            ShopTemplateMgr template = new ShopTemplateMgr(
                "/shop/templates/" + templateFileName, serverPath, wid);
            template.tType = TemplateType.RecommendIndex;
            template.openid = openid;
            template.OutPutHtml(wid);
        }
    }
}